package com.mfangsoft.zhuangjialong.article.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.mfangsoft.zhuangjialong.article.model.ArticleDetailModel;
import com.mfangsoft.zhuangjialong.article.model.ArticleEntity;
import com.mfangsoft.zhuangjialong.article.service.HelperArticleService;
import com.mfangsoft.zhuangjialong.article.service.impl.HelperArticleServiceImpl;
import com.mfangsoft.zhuangjialong.common.model.Page;
import com.mfangsoft.zhuangjialong.common.model.ResponseMessage;
import com.mfangsoft.zhuangjialong.common.utils.SysConstant;

@Controller(value="helperArticle")
@RequestMapping("/helper")
public class HelperArticleController {
	
	@Autowired
	private HelperArticleService helperArticleServiceImpl;
	/**
	 * 查询文章列表
	 * @param param
	 * @return
	 */
	@RequestMapping(value = "/querynews", method = RequestMethod.POST)
	@ResponseBody
	@CrossOrigin
	public ResponseMessage<Page<ArticleDetailModel>> querynews(@RequestBody Page<ArticleDetailModel> param){
		ResponseMessage<Page<ArticleDetailModel>> message=new ResponseMessage<>();
		try {
			Page<ArticleDetailModel> queryNews = helperArticleServiceImpl.queryNews(param);
			message.setCode(SysConstant.SUCCESS_CODE);
			message.setMessage(SysConstant.SUCCESS_MSG);
			message.setResult(queryNews);
		} catch (Exception e) {
			e.printStackTrace();
			message.setCode(SysConstant.FAILURE_CODE);
			message.setMessage(SysConstant.FAILURE_MSG);
		}
		return message;
	}
}
